import 'package:pull_to_refresh/pull_to_refresh.dart';

class ClassificationState {
  static const String layoutStandard = "standard";
  static const String layoutUniversal = "universal"; //外卖-通用
  static const String layoutShopWindow = "shopwindow"; //外卖-橱窗

  static const int sortDefault = 0;
  static const int sortSoldQuantity = 1;
  static const int sortPriceAsc = 2;
  static const int sortPriceDesc = 3;
  static const int sortOnSaleTime = 4;

  int level1ChooseIndex = 0;
  int level2ChooseIndex = 0;
  String templateNumId = "";
  String layout = layoutStandard;
  List categoryList = [];
  int sortType = sortDefault;
  List goodsList = [];
  RefreshController refreshController =
      RefreshController(initialRefresh: false);

  bool isStandardLayout() {
    return layout == layoutStandard;
  }

  bool isUniversalLayout() {
    return layout == layoutUniversal;
  }

  bool isShopWindowLayout() {
    return layout == layoutShopWindow;
  }

  void setSortType(int type) {
    sortType = type;
  }

  bool isDefaultSortType() {
    return sortType == sortDefault;
  }

  bool isSoldQuantitySortType() {
    return sortType == sortSoldQuantity;
  }

  bool isPriceSortType() {
    return sortType == sortPriceAsc || sortType == sortPriceDesc;
  }

  bool isOnSaleTimeSortType() {
    return sortType == sortOnSaleTime;
  }

  String getOrderByParams() {
    switch (sortType) {
      case sortSoldQuantity:
        return "sold_quantity desc";
      case sortPriceAsc:
        return "price asc";
      case sortPriceDesc:
        return "price desc";
      case sortOnSaleTime:
        return "onsale_time desc";
      default:
        return "";
    }
  }
}
